<template>
    <el-drawer v-model="isDrawerVisible" title="地址详情" :with-header="true">
        <div class="detail-card">
            <div class="card-header">
                <div class="detail-info">
                    <p><span class="info-label">地址ID:</span> {{ dizhi.dzid }}</p>
                    <p><span class="info-label">用户ID:</span> {{ dizhi.yhid }}</p>
                </div>
            </div>
            <div class="card-body">
                <div class="detail-section">
                    <h3 class="section-title">地址信息</h3>
                    <p class="section-content">{{ dizhi.address }}</p>
                </div>
            </div>
            <div class="card-footer">
                <el-button type="primary" @click="closeDrawer">关闭</el-button>
            </div>
        </div>
    </el-drawer>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// 控制抽屉的显示
const isDrawerVisible = ref(false);

const dizhi = ref({
    dzid: '',
    yhid: '',
    address: ''
});

// 接收父组件传递过来的对象数据
const handleDetailData = (obj) => {
    isDrawerVisible.value = true;
    dizhi.value = obj;
};

// 关闭抽屉
const closeDrawer = () => {
    isDrawerVisible.value = false;
};

// 将 handleDetailData 暴露给父组件
defineExpose({
    handleDetailData
});
</script>

<style scoped>
.detail-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #f58147;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-header {
    margin-bottom: 20px;
}

.detail-info {
    display: flex;
    gap: 20px;
}

.info-label {
    font-weight: bold;
    margin-right: 5px;
}

.card-body {
    flex: 1;
    margin-bottom: 20px;
}

.detail-section {
    margin-bottom: 20px;
}

.section-title {
    color: #666;
    margin-bottom: 10px;
}

.card-footer {
    text-align: right;
}
</style>